<?php
session_start();
require_once 'auth.php';

// 检查用户是否已登录
if (!isLoggedIn()) {
    echo "<script>window.top.window.stopUpload(0);</script>";
    exit;
}

// Edit upload location here
$destination_path = getcwd().DIRECTORY_SEPARATOR;

$result = 0;

$target_path = $destination_path . "uploads/" . basename( $_FILES['myfile']['name']);

if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
    $result = 1;
}

sleep(1);
?>

<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>
